package org.anddev.andengine.extension.svg.util.render;
/**
 * @author Eric Depta
 * @since 01:14:00 - 28.02.2011
 */
import org.anddev.andengine.opengl.util.FastFloatBuffer;
import org.anddev.andengine.opengl.vertex.VertexBuffer;



public class TriangleVertexBuffer extends VertexBuffer {
	
	public static final int VERTICES_PER_TRIANGLE = 3;
	
	public TriangleVertexBuffer(int pDrawType) {
		super(2 * VERTICES_PER_TRIANGLE, pDrawType);
	}
	
	public synchronized void update(float[] vertices) {
		final int[] bufferData = this.mBufferData;
		bufferData[0] = Float.floatToRawIntBits(vertices[0]);
		bufferData[1] = Float.floatToRawIntBits(vertices[1]);

		bufferData[2] = Float.floatToRawIntBits(vertices[2]);
		bufferData[3] = Float.floatToRawIntBits(vertices[3]);

		bufferData[4] = Float.floatToRawIntBits(vertices[4]);
		bufferData[5] = Float.floatToRawIntBits(vertices[5]);

		final FastFloatBuffer buffer = this.getFloatBuffer();
		buffer.position(0);
		buffer.put(bufferData);
		buffer.position(0);

		super.setHardwareBufferNeedsUpdate();
	}
}
